<?php

class User extends Model
{
  /*variables to pre-define here*/
  $security = new security();
  
  
  function __construct()
  {
    if(isset($_SESSION['username']))
    {
      $this->initiateUserSystem();
    }
    else
    {
      $this->initiateNewUser();
    }
  }

  private function initiateUserSystem();
  {
    //to do
    //grab user info
    //update last login table etc
  }

  private function initiateNewUser();
  {
    $this->LogInfo();
  }
  
  public function register($username, $passowrd, $email);
  { 
    $this->security->santiise($username);
    //query db for username here. If it returns with a match, generate an error array (as username is taken). ELSE, encrypt the password
    $this->security->EncPws($password);
    //set the sessions, etc
  }
  
  public function login($usenrame, $password)
  {
    $this->security->santiise($username);
    //query db for username here. If it returns with a match, encrypt the password and check if a match is returned also
    $this->security->EncPws($password);
    //if both return TRUE, set the sessions, etc
    //if it returns false, set an array of custom errors. 
  }
  
  public function isLoggedIn()
  {
    if(isset($_SESSOIN['username']))
    {
      return TRUE;
    }
    else
    {
      return FALSE;
    }
  }

}